<template>
	<view class="container">
		<view class="example">
			<uni-forms ref="form" :model="merchant" labelWidth="80px">
				<uni-forms-item label="商户名称" name="name">
					<uni-easyinput v-model="merchant.name" placeholder="请输入昵称" disabled />
				</uni-forms-item>
				<uni-forms-item label="所属城区" name="districtName">
					<uni-easyinput v-model="merchant.districtName" placeholder="请输入手机号码" disabled />
				</uni-forms-item>
				<uni-forms-item label="详细地址" name="address">
					<uni-easyinput v-model="merchant.address" disabled />
				</uni-forms-item>
				<uni-forms-item label="油池容积" name="oilPoolVolume">
					<uni-easyinput v-model="merchant.oilPoolVolume" disabled />
				</uni-forms-item>
				<uni-forms-item label="签约日期" name="signDate">
					<uni-easyinput v-model="merchant.signDate" disabled />
				</uni-forms-item>
				<uni-forms-item label="联系人姓名" name="contactPerson">
					<uni-easyinput v-model="merchant.contactPerson" disabled />
				</uni-forms-item>
				<uni-forms-item label="联系电话" name="phone">
					<uni-easyinput v-model="merchant.phone" disabled />
				</uni-forms-item>
				<uni-forms-item label="备注信息" name="notes">
					<uni-easyinput v-model="merchant.notes" disabled />
				</uni-forms-item>
				<uni-forms-item label="负责收油员姓名" name="oilCollector">
					<uni-easyinput v-model="merchant.oilCollector" disabled />
				</uni-forms-item>
				<uni-forms-item label="灶台油油桶数量" name="oilDrumCount">
					<uni-easyinput v-model="merchant.oilDrumCount" disabled />
				</uni-forms-item>
			</uni-forms>
			<!-- <button type="primary" @click="submit">提交</button> -->
		</view>
	</view>
</template>

<script>
	import {
		queryInfo
	} from "@/api/system/merchant.js"

	export default {
		data() {
			return {
				merchant: {
					id: null,
					districtName: null,
					address: null,
					oilPoolVolume: null,
					signDate: null,
					contactPerson: null,
					phone: null,
					notes: null,
					oilCollector: null,
					oilDrumCount: null,
				},
				// 查询参数
				queryParams: {
					districtId: null,
					name: null,
					address: null,
					oilPoolVolume: null,
					businessStatus: null,
					isSigned: null,
					type: null,
					signDate: null,
					expireDate: null,
					contactPerson: null,
					phone: null,
					notes: null,
					qrCode: null,
					oilCollector: null,
					oilDrumCount: null,
					hasGreaseInterceptor: null,
					hasGreaseTrap: null,
					collectionFrequency: null,
					lastCollectionDate: null,
					level: null,
					districtName: null,
				},
			}
		},
		onLoad(options) {
			// 获取商户详情
			this.queryMerchantInfo();
		},
		methods: {
			// 获取商户详情
			async queryMerchantInfo() {
				try {
					// 用户信息
					this.queryParams.phone = this.$store.state.user.phonenumber;
					console.log(this.queryParams)
					console.log(this.$store.state.user)
					const res = await queryInfo(this.queryParams);

					this.merchant = res.data;
					if(this.merchant == null){
						uni.showToast({
							title: '未获取到商户信息',
							icon: 'none'
						});
					}
				} catch (error) {
					console.log(error)
					
					uni.showToast({
						title: '加载失败',
						icon: 'none'
					});
				}
			},
		}
	}
</script>


<style lang="scss" scoped>
  page {
    background-color: #ffffff;
  }

  .example {
    padding: 15px;
    background-color: #fff;
  }

  .segmented-control {
    margin-bottom: 15px;
  }

  .button-group {
    margin-top: 15px;
    display: flex;
    justify-content: space-around;
  }

  .form-item {
    display: flex;
    align-items: center;
    flex: 1;
  }

  .button {
    display: flex;
    align-items: center;
    height: 35px;
    line-height: 35px;
    margin-left: 10px;
  }
</style>
